<template lang="pug">
.page
  .ApplyInvoice
    Modal(
      width="300"
      v-model="isShowDataUnCheckModal"
      title="是否确定退回"
      class-name="vertical-center-modal"
    )
      //- .text-center.mt-20.mb-20.font-16.font-weight 确定退回？
      //- .text-center.pb-10
      //-   Button.ml-10.mr-10(@click="cancel") 关闭
      //-   Button.ml-10.mr-10(type="primary" @click="ok") 确认
      .search-form.mb-10.pr-10
        Form.ivu-row.ivu-form-basic(ref="formData" :model="formData" :rules="rules" :label-width="90")
          FormItem.form-item.ivu-col.pr-20.mb-15(v-for="(item, index) of formItem" :label="item.label" :key="index" :class="item.style" :prop="item.prop")
            template(v-if="item.type === 'input'")
              Input(v-model="formData[item.model]" :placeholder="item.placeholder" clearable)

      .clearfix(slot="footer")
        Button(type="text" @click="cancel") 取消
        Button(type="primary" @click="ok" :loading="!isCanSubmit") 确定
</template>

<script>
import { BillApi } from '@/api/Bill.api.js'
export default {
  name: 'ApplyInvoice',

  data () {
    return {
      isCanSubmit: true,
      parentRow: null,
      isShowDataUnCheckModal: false,
      rowYear: '',
      rowMonth: '',
      formData: {
        remark: ''
      },
      formItem: [
        { type: 'input', label: '退回原因：', placeholder: '请输入退回原因', prop: 'remark', model: 'remark', style: 'ivu-col-span-24' },
      ],
      rules: {
        remark: [{ required: true, message: '请输入退回原因' }]
      },
    }
  },

  watch: {
  },

  mounted () {
  },

  methods: {
    ok () {
      // this.isShowDataUnCheckModal = false
      var params = {
        customerId: this.$route.query.companyId,
        year: this.rowYear,
        month: this.rowMonth,
        remark: this.formData.remark
      }
      this.$refs.formData.validate((valid) => {
        if (valid) {
          BillApi.unCheckBill(params).then(res => {
            console.log('核对完成: ', res)
            if (res.status === 200 && res.data.success) {
              this.$Message.success(res.data.message)
              this.isShowDataUnCheckModal = false
              this.$emit('query')
            } else {
              this.$Message.error({
                content: res.data.message,
                duration: 10,
                closable: true
              })
            }
          })
        }
      })
    },

    cancel () {
      this.isShowDataUnCheckModal = false
    }
  }
}
</script>

<style lang="less" scope>
</style>
